﻿Imports DTO
Imports System.Linq

Public Class LopDAO

    Public Function getClass_DAO(ByVal mak As Integer)
        Dim list As List(Of LopDTO) = New List(Of LopDTO)

        Dim context As DataproviderDataContext = New DataproviderDataContext()

        Dim listlop = From Lop In context.Lops
                      Select Lop
                      Where Lop.MaKhoi = mak

        For Each value As Lop In listlop
            Dim entity As LopDTO = New LopDTO()
            entity.MaLop = value.MaL
            entity.TenLop = value.TenLop
            entity.SiSo = value.SiSo

            list.Add(entity)
        Next
        Return list
    End Function

    Public Sub InsertNumberofST_DAO(ByVal ml As String)
        Dim context As DataproviderDataContext = New DataproviderDataContext()
        Dim l = (From lop In context.Lops _
                Where lop.MaL.Contains(ml) _
                Select lop).SingleOrDefault
        l.SiSo = l.SiSo + 1
        'Dim entity As LopDTO = New LopDTO()
        'entity.SiSo = entity.SiSo + 1

        context.SubmitChanges()
    End Sub

End Class
